home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / pcl4c60.zip / MINIMAL.C < prev    next >
Text File  |  1996-10-10  |  1KB  |  47 lines

  1. /*
  2. **   minimal.c (3/3/95)
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <conio.h>
  8. #include <dos.h>
  9. #include "pcl4c.h"
  10.  
  11. #define CTLZ 0x1a
  12. static char RxBuffer[128+16];
  13. static char TxBuffer[128+16];
  14.  
  15. void main(void)
  16. {int i, Seg;
  17.  char far *Ptr;
  18.  /* setup 128 byte receive buffer */
  19.  Ptr = (char far *)RxBuffer;
  20.  Seg = FP_SEG(Ptr) + ((FP_OFF(Ptr)+15)>>4);
  21.  SioRxBuf(COM1,Seg,Size128);
  22.  /* setup 128 byte transmit buffer */
  23.  Ptr = (char far *)TxBuffer;
  24.  Seg = FP_SEG(Ptr) + ((FP_OFF(Ptr)+15)>>4);
  25.  SioTxBuf(COM1,Seg,Size128);
  26.  /* set port parmameters & reset port */
  27.  SioParms(COM1,NoParity,OneStopBit,WordLength8);
  28.  SioReset(COM1,Baud9600);
  29.  printf("\nMINIMAL: COM%d @ 9600 Baud: Type ^Z to quit\n",1+COM1);
  30.  /* enter terminal loop */
  31.  while(1)
  32.    {/* was key pressed ? */
  33.     if(kbhit())
  34.       {i = getch();
  35.        if((char)i==CTLZ)
  36.          {/* restore COM port status & exit */
  37.           SioDone(COM1);
  38.           exit(0);
  39.          }
  40.        else SioPutc(COM1,(char)i);
  41.       } /* end if */
  42.     /* any incoming over serial port ? */
  43.     i = SioGetc(COM1,0);
  44.     if(i>-1) putch((char)i);
  45.    } /* end while */
  46. } /* end main */
  47.